angular.module('pa.controller', 
  [
  'pa.service',
  'ui.bootstrap'
  ])
.controller('NavController', ['$scope', '$location', 
function($scope,$location) {

}])
.controller('SubnetController', [
    '$scope','$location','PA', function($scope,$location,PA) {

    // $scope.ipp0 = '10';
    // $scope.ipp1 = '0';
    // $scope.ipp2 = '0';
    // $scope.ipp3 = '0';

    PA.getSubnet(function(sbs){
        $scope.sbs = sbs;
    });      
}])
.controller('HostController', [
    '$scope', '$routeParams', 'PA', function($scope, $routeParams, PA) {
    var sb = $routeParams.sb;
    var _sbarr = sb.split('.');
    $scope.ipp0 = _sbarr[0];
    $scope.ipp1 = _sbarr[1];
    $scope.ipp2 = _sbarr[2];
    // $scope.ipp3 = '0';



    PA.getHostsBySubnet(sb, function(hosts){
        $scope.hosts = hosts;
    });      
}])
.controller('PortController', [
    '$scope', '$routeParams', 'PA','Utils', function($scope, $routeParams, PA,Utils) {
    var ip = $routeParams.ip;
    var network = Utils.ip2network(ip);
    $scope.navs = [
        {label:'所有子网',href:'/subnet'},
        {label:network, href:'/subnet/'+network},
        {label:ip, href:'/ip/'+ip}
    ];

    $scope.portFilter = function(e,i){
        console.log(e);
    };

    PA.getHostByIP(ip, function(host){
        $scope.host = host;
    });      
}]);



